class Solution:
    def destCity(self, paths: list[list[str]]) -> str:
        # 方法一：
        # for path in paths:
        #     if not any([path[1] == p[0] for p in paths]):
        #         return path[1]
        # 方法二：
        # for path in paths:
        #     is_departure = False
        #     for p in paths:
        #         if path[1] == p[0]:
        #             is_departure = True
        #             break
        #     if not is_departure:
        #         return path[1]
        # 方法三：
        # departures = set([p[0] for p in paths])
        # arrivals = set([p[1] for p in paths])
        # return (arrivals - departures).pop()
        # 方法四:（灵神）
        # set_a = set(p[0] for p in paths)
        # return next(p[1] for p in paths if p[1] not in set_a)
        # 方法五：
        a_list = []
        b_list = []
        for path in paths:
            a_list.append(path[0])
            b_list.append(path[1])
        for city in b_list:
            if city not in a_list:
                return city


paths = [["London", "New York"], ["New York", "Lima"], ["Lima", "Sao Paulo"]]
aa = Solution()
bb = aa.destCity(paths)
print(bb)
